﻿var ceilmeter = jQuery.parseJSON(localStorage.getItem('ceilmeterdata'));



var app = angular.module("nvd3TestApp", ['nvd3ChartDirectives']);
//value[順序,資料量] key顯示於圖中資料框的資料名稱
function ExampleCtrl($scope){
/*
	for(var i=0;i<6;i++){
		console.log(ceilmeter[i]['counter_unit']);
		console.log(ceilmeter[i]['counter_volume']);
		console.log(ceilmeter[i]['recorded_at']);		
	}
*/
	var str = "";
	for(var i=0;i<6;i++){
					str= str + "[" + (i+1) + "," + parseInt(ceilmeter[i]['counter_volume'])+"],";					
	}
	console.log(str);
	$scope.exampleData = 
		[{
			"key": ("單位(" + ceilmeter[0]['counter_unit'] + ")"),
			"values": [
				[1,(ceilmeter[5]['counter_volume'])],
				[2,(ceilmeter[4]['counter_volume'])],
				[3,(ceilmeter[3]['counter_volume'])],
				[4,(ceilmeter[2]['counter_volume'])],
				[5,(ceilmeter[1]['counter_volume'])],
				[6,(ceilmeter[0]['counter_volume'])],
			]
		}];

	//configuration examples
	$scope.xAxisTickFormat = function(){
		return function(d){
//          return d3.time.format('%X')(new Date(d));  //uncomment for time format
				//console.log(ceilmeter[i]['counter_unit']);			
			return ceilmeter[d-1]['recorded_at'];
		}
	}
}